<?php
session_start();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Wellcome to Charity Organization!</title>
</head>

<body>
<div id="container">
		<div id="header">
			<h1>Charity<span class="off">Organization</span></h1>
        </div>   
        <div id="menu">
        </div>
    
		<div id="content">
        <div id="content_top"></div>
		<div id="content_main">
		<?php
		$link =mysql_connect('localhost','root','');
		if (!$link) {
			die('Not connected : ' . mysql_error());
		}
		$db_selected = mysql_select_db('seproject', $link);
		if (!$db_selected) {
			die ('Cannot useSeproject : ' . mysql_error());
		}
		if(isset($_POST["captcha"])&&$_POST["captcha"]!=""&&$_SESSION["code"]==$_POST["captcha"])
		{
			//echo "Correct Code Entered";
			$Username=$_POST["Username"];
			$query=mysql_query("SELECT Email,Password FROM user where `UserName`='$Username'");
			$a=mysql_fetch_row($query);
			$Email=$a[0];
			$Password=$a[1];
			
			$to = $Email;
			$subject = "Forgot Password";
			$message = "Hello! Dear"+$Username+"!/nThis is your password:	"+$Password;
			$from = "someonelse@example.com";
			$headers = "From:" . $from;
			mail($to,$subject,$message,$headers);
			echo "Your password has been sent to your mail.";
			?>
			<a href="index.php">Go to homepage</a>	
			<?php
		}
		else
		{
			echo "Wrong Code Entered!";
			?>
			<a href="ForgetPass.php">Back</a>	
			<?php
		}
		?>
        </div>
        <div id="content_bottom"></div>
      </div>
   </div>
</body>
</html>
